import {
  version1,
  overviewApi,
  trendApi,
  structureOverviewApi,
} from '../src/api';

const delay = (ms: number) =>
  new Promise(resolve => {
    setTimeout(resolve, ms);
  });

export default {
  // 1. 数据总览
  [`GET ${version1}${overviewApi}`]: (req: any, res: any) => {
    delay(1000);
    res.send({
      data: {
        devices: 42000,
        down_platforms: 32,
        up_platforms: 23,
        up_platform_devices: 3299,
      },
      message: '',
      request_id: '56e83d08ea1e4c209af9b857c2a9abf8',
    });
  },

  // 2. 接入数据趋势
  [`GET ${version1}${trendApi}`]: (req: any, res: any) => {
    delay(1000);
    res.send({
      data: {
        objectStatistics: [
          {
            timestamp: 1603209600,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 10 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
          {
            timestamp: 1603296000,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 20 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
          {
            timestamp: 1603209600,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 30 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
          {
            timestamp: 1603296000,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 60 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
          {
            timestamp: 1603209600,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 80 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
          {
            timestamp: 1603296000,
            num: {
              snapshot: 10,
              record: 10,
              other: 10,
            },
            space: {
              snapshot: 100,
              record: 60 * 1024 * 1024 * 1024,
              other: 100,
            },
          },
        ],
      },
      message: '',
      request_id: '56e83d08ea1e4c209af9b857c2a9abf8',
    });
  },

  // 3. 结构化统计
  [`GET ${version1}${structureOverviewApi}`]: (req: any, res: any) => {
    delay(1000);
    res.send({
      data: {
        pictures: 1000,
        videos: 232,
        picture_qps_max: 100,
        picture_qps: 99,
        video_qps_max: 20,
        video_qps: 12,
        structured_objects: 23112,
        filtered_objects: 2321,
      },
      message: '',
      request_id: '56e83d08ea1e4c209af9b857c2a9abf8',
    });
  },
};
